 
    //转化数据
    function changeData(obj){
    let arr=[]
    for(let k in obj){
    let str=k+'='+obj[k]
    arr.push(str)
    }
    return arr.join('&')
    }
//{id:1}id=1&name=111
//    console.log( changeData({id:1,name:111}));
   
   function myAjax(options){
    let sq=changeData(options.data)
    let xhr= new XMLHttpRequest()
    if(options.method.toUpperCase()==='GET'){
        xhr.open('GET',options.url+'?'+sq),
        xhr.send()
    }else if(options.method.toUpperCase()==='POST'){

        xhr.open('POST',options.url),
        xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded')
        xhr.send(sq)
    }
    
    // 1.判断状态
    xhr.onreadystatechange=function(){
        if(xhr.readyState===4&&xhr.status===200){
            options.success(JSON.parse(xhr.responseText))
        }
    }


   }